package com.ecjtu.stadiumre_servations.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ecjtu.stadiumre_servations.entity.domain.Student;
import com.ecjtu.stadiumre_servations.entity.dto.UserDTO;
import com.ecjtu.stadiumre_servations.response.Result;
import com.ecjtu.stadiumre_servations.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    @PostMapping("/isUserExistsInStudent")
    public boolean isUserExistsInStudent(@RequestBody UserDTO userDTO){
        return studentService.isUserExistsInStudent(userDTO);
    }
    @PostMapping("/isUserIdCardCorrect")
    public boolean isUserIdCardCorrect(@RequestBody UserDTO userDTO){
        return studentService.isUserIdCardCorrect(userDTO);
    }
    @GetMapping("/studentList")
    public Result studentList(Page<Student> page){
        return studentService.studentList(page);
    }
    @DeleteMapping("/removeStudent")
    public Result removeStudent(@RequestParam String studentId){
        return studentService.removeStudent(studentId);
    }
    @PutMapping("/addStudent")
    public Result addStudent(@RequestBody Student student){
        return studentService.addStudent(student);
    }
}
